<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
    <script src="./libs/vue2.js"></script>
</head>
<body>
    <div id="app">
        <ul>
            <!-- vue2中, 会根据ref属性的属性值自动创建一个同名的数组, 用于保存所有的列表子元素 -->
            <li ref="list" v-for="item in list">{{item}}</li>
        </ul>
        <button @click="handler">操作元素</button>
    </div>
</body>
<script>
    new Vue({
        el:'#app',
        data:{
            list:['苹果','香蕉','草莓','榴莲','水密桃']
        },
        methods:{
            handler(){
                // console.log(this.$refs.list);
                this.$refs.list[4].style.backgroundColor='orange';
            }
        }
    });
</script>
</html>